<?php
namespace Shopadmin\Model;
use Think\Model;
class EventsGiftsModel extends Model {
	public $wherestr;
	public $rollPage;
	public $listRows;
	public $Page;
	public $field = '`id`,`type`,`status`,`level`,`name`,`details`,`price`,`probability`,`isshow`,`quantity`,`pic_url`,`num_iids`,`event_id`,`promoid`,`tagid`,`sid`';
	public function getgifts(){
		Vendor('Page');
		$total = $this->where($this->wherestr)->count();
		$this->Page = new \Page($total,$this->listRows);
		$this->Page->rollPage=$this->rollPage;
		$show = $this->Page->show();
		$data = $this->where($this->wherestr)
				  ->limit($this->Page->firstRow.','.$this->Page->listRows)
				  ->getField($this->field);
		foreach($data as $k=>$gift){
			$data[$k]["probability"]=($data[$k]["probability"]/100)."%";
			$data[$k]["level"]=getlevel($data[$k]["level"]);
			foreach($tools as $tool){
				if($data[$k]["type"]==$tool["id"]){
					$data[$k]["type"]=$tool["name"];
				}
			}
		}
		$this->data = $data;
	}
}